# 一些自定义函数


# Exit if there's no match (--exit-0)
# Bypass fuzzy finder if there's only one match (--select-1)
fe() {
  IFS=$'\n' files=($(fzf -e -q "$1" --multi -1 -0))
  # IFS=$'\n' files=($(fzf-tmux -e -q "$1" --multi -1 -0))
  [[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
}

# fo() {
#   IFS=$'\n' out=("$(fzf-tmux -e --query="$1" --exit-0 --expect=ctrl-o,ctrl-e)")
#   key=$(head -1 <<< "$out")
#   file=$(head -2 <<< "$out" | tail -1)
#   if [ -n "$file" ]; then
#     [ "$key" = ctrl-o ] && open "$file" || ${EDITOR:-nvim} "$file"
#   fi
# }


fcd() {
    if [ -z $1 ]; then
        DIR=`fd -td -E /proc -E /sys -E .git -H  | fzf-tmux` && cd $DIR
    else
        DIR=`fd . -td -E /proc -E /sys -E .git -H $1 | fzf-tmux -q $2` && cd $DIR
    fi
}
